package com.huawei.appgallery.forum.posts.card;

import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.text.TextPaint;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.huawei.appgallery.forum.posts.buoy.action.OpenPostRecommendAction;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.plugin.gameservice.view.TransferActivity;
import o.bsu;
import o.bzd.b;
import o.bzd.d;
import o.cdb;
import o.cgz;
import o.faj;

public class BuoyForumRecommendCard extends ForumRecommendCard {
    private ImageView ʽ;

    public BuoyForumRecommendCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        this.ˋ = (ImageView) view.findViewById(b.ˎ);
        this.ˊ = (TextView) view.findViewById(b.ॱ);
        this.ॱ = (TextView) view.findViewById(b.ˋ);
        this.ˎ = (TextView) view.findViewById(b.ˏ);
        this.ˏ = (TextView) view.findViewById(b.ˊ);
        this.ʽ = (ImageView) view.findViewById(b.ॱॱ);
        return this;
    }

    public void ˏ(final CardBean cardBean) {
        super.ˏ(cardBean);
        ˎ();
        ˉ().setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ BuoyForumRecommendCard ˎ;

            public void onClick(View view) {
                if (cardBean instanceof BaseCardBean) {
                    BaseCardBean baseCardBean = (BaseCardBean) cardBean;
                    Intent intent = new Intent(this.ˎ.ˉ().getContext(), TransferActivity.class);
                    intent.setAction(OpenPostRecommendAction.ACTION_OPEN_FORUM_POST_RECOMMEND);
                    intent.putExtra("detailId", baseCardBean.ॱॱ());
                    intent.putExtra("trace", baseCardBean.u_());
                    ((faj) cdb.ॱ(faj.class)).ˊ(this.ˎ.ˉ().getContext(), TransferActivity.class, intent);
                }
            }
        });
    }

    private void ˎ() {
        Rect rect;
        float measureText;
        float measureText2;
        float f = 0.0f;
        if (this.ˊ.getVisibility() == 0) {
            rect = new Rect();
            TextPaint paint = this.ˊ.getPaint();
            String charSequence = this.ˊ.getText().toString();
            paint.getTextBounds(charSequence, 0, charSequence.length(), rect);
            measureText = paint.measureText(charSequence);
        } else {
            measureText = 0.0f;
        }
        if (this.ˎ.getVisibility() == 0) {
            rect = new Rect();
            paint = this.ˎ.getPaint();
            charSequence = this.ˎ.getText().toString();
            paint.getTextBounds(charSequence, 0, charSequence.length(), rect);
            measureText2 = paint.measureText(charSequence);
        } else {
            measureText2 = measureText;
        }
        if (this.ॱ.getVisibility() == 0) {
            rect = new Rect();
            TextPaint paint2 = this.ॱ.getPaint();
            charSequence = this.ॱ.getText().toString();
            paint2.getTextBounds(charSequence, 0, charSequence.length(), rect);
            f = paint2.measureText(charSequence);
        }
        rect = new Rect();
        TextPaint paint3 = this.ˏ.getPaint();
        String charSequence2 = this.ˏ.getText().toString();
        paint3.getTextBounds(charSequence2, 0, charSequence2.length(), rect);
        float measureText3 = paint3.measureText(charSequence2);
        int dimensionPixelSize = (ˉ().getContext().getResources().getDimensionPixelSize(d.ˊ) * 4) + ˉ().getContext().getResources().getDimensionPixelSize(d.ʼ);
        this.ʽ.measure(0, 0);
        float ˋ = (((float) ((bsu.ˋ(ˉ().getContext()) - dimensionPixelSize) - this.ʽ.getMeasuredWidth())) - measureText3) - ((float) ˉ().getContext().getResources().getDimensionPixelSize(d.ॱ));
        LayoutParams layoutParams = (LayoutParams) this.ˏ.getLayoutParams();
        if (measureText2 > ˋ || r1 > ˋ) {
            layoutParams.width = (int) (measureText3 / 2.0f);
        } else {
            layoutParams.width = (int) measureText3;
        }
        this.ˏ.setLayoutParams(layoutParams);
    }
}
